﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class FormModel extends BaseModel
{

    var $table  = 'form';	

	
    /* 插入数据 */
    function post($data)
    {    
	    
    
		return $this->IU_Sql_Exe(array ('data' => $data, 'mode' => 'INSERT'));

        
    }

    function show()
    {   
	
		 $info = $this->S_Sql_Exe(array('fields' =>'*'));    
		 return $info;
        
    }

    /* 删除数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
		$time = time();  	      
		return $this->IU_Sql_Exe(array ('data' => $data,'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editsort($id ='',$data = '')
    {   
     
		return $this->IU_Sql_Exe(array ('data' => array('sort'=>"$data[sort]"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }


    /* 通过id取出一条数据 */
    function get_module_max_id()
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'id','order' =>" id desc ",'return' =>'one'));    
		 return $info['id'];
        
    }


    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));    
		 return $info;
        
    }
    /* 通过id取出一条数据 */
    function check_name($name ='',$appname ='')
    {    
	    $conditions = '';
		$icon = false;
	    if($name)
		{
		$conditions .= "name='{$name}'" ;
		$icon = true;
		}

	    if($appname)
		{
		      if($icon == true)
			  {
		       $conditions .= " or " ;				  
			  }
	
		       $conditions .= "appname='{$appname}'" ;
		}
		  
		 $info = $this->S_Sql_Exe(array('fields' =>'id','conditions' =>"{$conditions}",'return' =>'one'));   
		  
		 return $info['id'];
        
    }


}




?>